﻿Imports System
Imports System.IO
Imports System.PlatformID
Imports System.IO.File
Imports System.Math

Public Class DiskControl

    Private Sub DiskControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim name As String
        name = My.Computer.FileSystem.GetDriveInfo(Environ("SystemDrive")).Name
        Label4.Text = name
        'Dim freespace As Long
        'freespace = My.Computer.FileSystem.GetDriveInfo(Environ("SystemDrive")).AvailableFreeSpace / 1073741824
        'Label5.Text = freespace & " GB "
        'Dim totalsize As Long
        'totalsize = My.Computer.FileSystem.GetDriveInfo(Environ("SystemDrive")).TotalSize / 1073741824
        'Label6.Text = totalsize & " GB "

        'Dim dvr As New DriveInfo(Environ("SystemDrive"))
        'TextBox1.Text = CStr(dvr.AvailableFreeSpace / 1073741824)
        'TextBox2.Text = CStr(dvr.TotalSize / 1073741824)
        'TextBox3.Text = CStr(Val(TextBox2.Text) - Val(TextBox1.Text))

        'ProgressBar1.Maximum = TextBox2.Text
        'ProgressBar1.Value = TextBox3.Text

    End Sub

    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            Dim freespace As Long
            freespace = My.Computer.FileSystem.GetDriveInfo(Environ("SystemDrive")).AvailableFreeSpace / 1073741824
            Label5.Text = freespace & " GB "
            Dim totalsize As Long
            totalsize = My.Computer.FileSystem.GetDriveInfo(Environ("SystemDrive")).TotalSize / 1073741824
            Label6.Text = totalsize & " GB "

            Dim dvr As New DriveInfo(Environ("SystemDrive"))
            TextBox1.Text = CStr(dvr.AvailableFreeSpace / 1073741824)
            TextBox2.Text = CStr(dvr.TotalSize / 1073741824)
            TextBox3.Text = CStr(Val(TextBox2.Text) - Val(TextBox1.Text))

            ProgressBar1.Maximum = TextBox2.Text
            ProgressBar1.Value = TextBox3.Text
            Label10.Text = ProgressBar1.Value

            Label8.Text = Label5.Text + "free"
            Label9.Text = "of " + Label6.Text
        Catch ex As Exception

        End Try
    End Sub

End Class
